package com.yi.mall.api;

import com.yi.mall.common.utils.Result;
import com.yi.mall.common.model.DTO.StockDTO;
import com.yi.mall.common.model.SkuInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(contextId = "skuInfo",value = "mall-goods-service",fallback = SkuInfoFeignFallback.class)
public interface SkuInfoFeign {
    /**
     * 按商品id查询
     * @param id 请求参数与对应的控制器一样
     * @return
     */
    @GetMapping("/goods/skuInfo/{id}") // 请求地址是控制的API（发送请求到哪个控制器）
    public Result getById(@PathVariable("id") Long id);
    /**
     * 按类别名称和品牌名称查询
     * @param categoryName 参数需要用@RequestParam注解
     * @param brandName
     * @return
     */
    @GetMapping("/goods/skuInfo/find")
    public Result listByCondition(
            @RequestParam("categoryName") String categoryName,
            @RequestParam("brandName") String brandName);
    /**
     * 修改商品库存信息
     * @param skuInfo
     * @return
     */
    @PutMapping("/goods/skuInfo")
    public Result update(@RequestBody SkuInfo skuInfo);

    @PostMapping("/skuInfo/dcount")
    public Result dcount(@RequestBody List<StockDTO> stock);
    @GetMapping( "/skuInfo/listAll")
    public Result listAll();
}
